package com.ddzh.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ddzh.vo.AuthMenuTreeVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AuthMenuTreeVoMapper extends BaseMapper<AuthMenuTreeVo> {

    @Select("select ut.username,ut.password,mt.*\n" +
            "from user_t ut left join user_role_t urt on ut.id=urt.user_id\n" +
            "left join role_t rt  on rt.id=urt.role_id\n" +
            "left join role_menu_t rmt on rmt.role_id=rt.id\n" +
            "left join menu_t mt on mt.id=rmt.menu_id\n" +
            "where ut.username=#{username}")
    AuthMenuTreeVo getAuthMenuByUsername(@Param("username") String username);

    @Select("select rt.role_name\n" +
            "from user_t ut left join user_role_t urt on ut.id=urt.user_id\n" +
            "               left join role_t rt  on rt.id=urt.role_id\n" +
            "where ut.username=#{usermame};")
    List<String> getRoleByUsername(@Param("usermame") String usermame);

    @Select("select password from user_t where username=#{username}")
    String getPasswordByUsername(@Param("username") String usermame);

    @Select("select username  from user_t")
    List<String> findAllUsername();

}
